package com.project.logistics.config;

/**
 * Created by94988 on 2021/2/16 10:30
 */
import com.project.logistics.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")//addPathPatterns：设置要拦截的请求，"/**"表示拦截所有请求
                //excludePathPatterns：表示要把那些请求排除在外,这里是把所有静态资源访问请求都排除在外
                .excludePathPatterns("/","/photos/**","/user","/user/login","/html/**","/charts/**","/datatable/**","/css/**","/fonts/**","/images/**", "/js/**");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/photos/**").addResourceLocations("file:E:\\javaee\\CODE\\logisticsSystem-v3\\src\\main\\resources\\static\\photos\\");
    }
}
